package com.offcn.service.impl;



import com.offcn.mapper.RoleMapper;
import com.offcn.mapper.RoleMemberMapper;
import com.offcn.pojo.*;
import com.offcn.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Autowired
    RoleMemberMapper roleMemberMapper;

    @Override
    public List<Role> selectRoleByMemberSession(Member memberSession) {

        RoleMemberExample exp1 = new RoleMemberExample();
        RoleMemberExample.Criteria criteria = exp1.createCriteria();
        criteria.andMemberidEqualTo(memberSession.getMid());
        List<RoleMember> roleMembers = roleMemberMapper.selectByExample(exp1);
        Long roleid = roleMembers.get(0).getRoleid();

        if(roleid==1L){
            RoleExample exp2 = new RoleExample();
            RoleExample.Criteria criteria1 = exp2.createCriteria();
            criteria1.andIdGreaterThan(roleid);
            List<Role> roleList = roleMapper.selectByExample(exp2);
            return roleList;

        }
        if(roleid==2L){
            RoleExample exp2 = new RoleExample();
            RoleExample.Criteria criteria1 = exp2.createCriteria();
            criteria1.andIdGreaterThan(roleid);
            List<Role> roleList = roleMapper.selectByExample(exp2);
            return roleList;
        }



        return null;
    }
}
